import threading
import redis
class RedisReciver(threading.Thread):
    def __init__(self,host,queue,channel='quotation',port=6379,db=0):
        threading.Thread.__init__(self)
        self.queue = queue
        self.channel = channel
        self.host = host
        self.port = port
        self.db = db

    def run(self):
        self._rc = rc = redis.Redis(host=self.host,port = self.port,db = self.db);
        self._ps = ps = rc.pubsub()
        ps.subscribe(self.channel)
        for item in ps.listen():
            if item['type'] == 'message':
                self.queue.put(item['data'].decode('utf8'))
         